# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Tests for LLVM libc stdlib.h functions.

load("//libc/test:libc_test_rules.bzl", "libc_test")

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

cc_library(
    name = "atoi_test_helper",
    hdrs = ["AtoiTest.h"],
    deps = [
        "//libc:__support_cpp_type_traits",
        "//libc/test/UnitTest:LibcUnitTest",
    ],
)

libc_test(
    name = "atoi_test",
    srcs = ["atoi_test.cpp"],
    libc_function_deps = [
        "//libc:atoi",
    ],
    deps = [":atoi_test_helper"],
)

libc_test(
    name = "atol_test",
    srcs = ["atol_test.cpp"],
    libc_function_deps = [
        "//libc:atol",
    ],
    deps = [":atoi_test_helper"],
)

libc_test(
    name = "atoll_test",
    srcs = ["atoll_test.cpp"],
    libc_function_deps = [
        "//libc:atoll",
    ],
    deps = [":atoi_test_helper"],
)

libc_test(
    name = "atof_test",
    srcs = ["atof_test.cpp"],
    libc_function_deps = [
        "//libc:atof",
    ],
    deps = [
        "//libc:__support_fputil_fp_bits",
    ],
)

libc_test(
    name = "bsearch_test",
    srcs = ["bsearch_test.cpp"],
    libc_function_deps = [
        "//libc:bsearch",
    ],
)

libc_test(
    name = "qsort_test",
    srcs = ["qsort_test.cpp"],
    libc_function_deps = [
        "//libc:qsort",
    ],
)

cc_library(
    name = "strtol_test_helper",
    hdrs = ["StrtolTest.h"],
    deps = [
        "//libc:__support_cpp_limits",
        "//libc:__support_cpp_type_traits",
        "//libc:errno.__internal__",
        "//libc/test/UnitTest:LibcUnitTest",
    ],
)

libc_test(
    name = "strtol_test",
    srcs = ["strtol_test.cpp"],
    libc_function_deps = [
        "//libc:strtol",
    ],
    deps = [":strtol_test_helper"],
)

libc_test(
    name = "strtoll_test",
    srcs = ["strtoll_test.cpp"],
    libc_function_deps = [
        "//libc:strtoll",
    ],
    deps = [":strtol_test_helper"],
)

libc_test(
    name = "strtoul_test",
    srcs = ["strtoul_test.cpp"],
    libc_function_deps = [
        "//libc:strtoul",
    ],
    deps = [":strtol_test_helper"],
)

libc_test(
    name = "strtoull_test",
    srcs = ["strtoull_test.cpp"],
    libc_function_deps = [
        "//libc:strtoull",
    ],
    deps = [":strtol_test_helper"],
)

libc_test(
    name = "strtof_test",
    srcs = ["strtof_test.cpp"],
    libc_function_deps = [
        "//libc:strtof",
    ],
    deps = [
        "//libc:__support_fputil_fp_bits",
        "//libc/utils/testutils:libc_test_utils",
    ],
)

libc_test(
    name = "strtod_test",
    srcs = ["strtod_test.cpp"],
    libc_function_deps = [
        "//libc:strtod",
    ],
    deps = [
        "//libc:__support_fputil_fp_bits",
        "//libc/utils/testutils:libc_test_utils",
    ],
)

libc_test(
    name = "strtold_test",
    srcs = ["strtold_test.cpp"],
    libc_function_deps = [
        "//libc:strtold",
    ],
    deps = [
        "//libc:__support_fputil_fp_bits",
        "//libc:__support_uint128",
    ],
)
